﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QL_Luong.Entities;
using System.Data;

namespace QL_Luong.DataLayer
{
    class TaiKhoanDAL
    {
        DataAccessHelper db = new DataAccessHelper();

        //Xac dinh quyen cua mot tai khoan
        public static object GetQuyen(string id, string pass)
        {
            DataAccessHelper db = new DataAccessHelper();
            object quyen = db.GetVaule(String.Format("Select maNhom from TaiKhoan where userID = '{0}' and pass = '{1}'", id, pass));
            return quyen;      
        }

        //Lay ten nhom quyen cua mot tai khoan
        public static object GetTenQuen(string id, string pass)
        {
            DataAccessHelper db = new DataAccessHelper();
            object tenquyen = db.GetVaule(String.Format("select tenNhom from NhomQuyen join TaiKhoan on NhomQuyen.maNhom = TaiKhoan.maNhom where userID = '{0}' and pass = '{1}'", id, pass));
            return tenquyen; 
        }

        //Lay danh sach tai khoan
        public static List<TaiKhoan> GetList()
        {
            DataAccessHelper db = new DataAccessHelper();
            DataTable dt = db.GetDataTable("Select * From TaiKhoan");
            List<TaiKhoan> list = new List<TaiKhoan>();
            foreach (DataRow row in dt.Rows)
            {
                list.Add(new TaiKhoan(row));
            }

            return list;
        }

        //Thuc thi thu tuc

        

    }
}
